package Java常用类的学习;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

class StringAddress{
    private String s;
    public StringAddress(String s){
        this.s=s;
    }
    public String toString(){
        return super.toString()+"---"+s;
    }
}

public class CollectionsOfList {
    public static void main(String[] args) {
//        Collections.nCopies()方法返回由指定的4个StringAddress对象所组成的不可变列表
        List<StringAddress> list=new ArrayList<StringAddress>(Collections.nCopies(4,new StringAddress("Hello")));
        System.out.println(list);
//        使用指定元素替换列表中的所有元素
        Collections.fill(list,new StringAddress("world"));
        List<String>list1= Arrays.asList(new String []{ "spring","summer","autumn","winter"});
        Collections.sort(list1);
        System.out.println(Collections.max(list1));
        System.out.println(Collections.min(list1));
        System.out.println(Collections.binarySearch(list1,"spring"));
        System.out.println(Arrays.toString(list1.toArray()));
        Collections.shuffle(list1);
//        Arrays.toString()方法将某个Array数组转换成字符串，里面的参数是数组
//        lists1.toArray();转换成Array
        System.out.println(Arrays.toString(list1.toArray()));
    }
}
